package com.zhouyu.config.processor;

import com.zhouyu.dto.AlipayTranDto;
import com.zhouyu.dto.CommonPayOutDto;
import com.zhouyu.entity.CommonPayEntity;

import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description:将读取对象转化为pojo
 */
@Component
public class AlipayDbProcessor implements ItemProcessor<AlipayTranDto, CommonPayEntity> {
  @Override
  public CommonPayEntity process(AlipayTranDto alipayTranDto) throws Exception {
    CommonPayEntity commonPayEntity = new CommonPayEntity();
    BeanUtils.copyProperties(alipayTranDto,commonPayEntity);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String dateNowStr = sdf.format(new Date());
    commonPayEntity.setTranDate(dateNowStr);
    commonPayEntity.setMerId("00000002");
    return commonPayEntity;
  }
}
